//============================================================================
// Name        : MutualExclusion.h
// Author      : Husheng Zhou
// Version     :
// Copyright   : S^3 lab, UTD
// Description : Implement Ricart's Mutual Exclusion Algorithm
//============================================================================

#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <algorithm>
#include <bitset>
#include <list>
using namespace std;

#define PROCESS_NUM 3;

class Process
{
public:
	bool CreateProcess(int proc_id);
	void Initialize(int proc_id);
	int GetHighestSeqNum(Process proc);
	bool RequestCS();
	bool ReleaseCS();

private:
	int proc_id;
	int outstanding_reply_num;
	bool request_cs;
	int highest_seq_num;
	list<Msg> l_delayed;
	list<Msg> l_deffered_reply;
	list<Msg> l_requested;
};



class Msg
{
public:

private:
	int src;
	int dst;
	int msg_id;
	int type;//0 request; 1 reply
};
